package com.chanceit.ssss.data;

import org.gl.utils.lg;

public class ExceptionCodeParsh {
	private final static String[] exception = new String[] { "当前车速", "发送机转速", "电瓶电压",
			"冷却液温度", "发动机负载", "节气门位置", "大气压", "进气歧管绝对压力", "空气流量", "环境空气温度",
			"进气温度", "OBD协议", "OBD标准", "燃油量", "未知异常", "未知异常" };
	private final static String TAG = "ExceptionCodeParsh";
	/**
	 * 获取异常的白话文标题
	 * 
	 * @param o
	 * @return
	 */
	public static String parshExcepiton(Object o,String value) {
		char[] chas = o.toString().toCharArray();//将异常码转化成char数组
		String[] valueStringArray = value.split(",");//将异常名称转化成string数组
		String exString = "";
		try {
			for (int j = 0; j < valueStringArray.length; j++) {
				if (j % 2 == 1) {
					String s = "" + chas[j] + chas[j - 1];
					if (!s.equals("00")) {
						if ((chas[j - 1] + "").equals("1")) {
							exString += exception[j / 2] + "过高:"+valueStringArray[j/2]+"\n";
						} 
						if ((chas[j] + "").equals("1")) {
							exString += exception[j / 2] + "过低:"+valueStringArray[j/2]+"\n";
						}
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			lg.e(TAG, "parshExcepiton:valueStringArray is short");
		}

		return exString;
	}
}
